home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Blitter / RamboWorm.s < prev    next >
Encoding:
Text File  |  1997-05-01  |  5.5 KB  |  276 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Bob example
  3. ;-----------
  4. ;This example blits a Worm from an IFF file onto a double buffered screen.
  5. ;The RESTORE mode is used to put the background back.
  6.  
  7.     INCDIR    "INCLUDES:"
  8.     INCLUDE    "games/games_lib.i"
  9.     INCLUDE    "games/games.i"
  10.  
  11. CALL    MACRO
  12.     jsr    _LVO\1(a6)
  13.     ENDM
  14.  
  15.     SECTION    "RamboWorm",CODE
  16.  
  17. ;===========================================================================;
  18. ;                             INITIALISE DEMO
  19. ;===========================================================================;
  20.  
  21.     STARTGMS
  22.  
  23. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  24.     move.l    GMSBase(pc),a6    ;Activate user preferences.
  25.     CALL    AllocBlitter
  26.     tst.l    d0
  27.     bne    .Error_Blitter
  28.  
  29.     CALL    AllocAudio
  30.     tst.l    d0
  31.     bne    .Error_Audio
  32.  
  33.     lea    ScreenTags(pc),a0    ;Initialise the screen.
  34.     CALL    AddScreen
  35.     tst.l    d0
  36.     beq    .Error_Screen
  37.  
  38. ;---------------------------------------------------------------------------;
  39. ;Load a picture into the background of the screen.  We have to set the correct
  40. ;palette and copy it to our second buffer as part of this process.
  41.  
  42.     move.l    Screen(pc),a0
  43.     lea    PIC_BackgroundTags(pc),a1
  44.     move.l    GS_MemPtr2(a0),Data
  45.     CALL    LoadPic
  46.     tst.l    d0
  47.     beq.s    .Error_Picture
  48.  
  49.     move.l    PIC_Background(pc),a1
  50.     move.l    PIC_Palette(a1),GS_Palette(a0)
  51.     CALL    UpdatePalette
  52.  
  53.     move.l    Screen(pc),a0
  54.     CALL    SwapBuffers
  55.     moveq    #BUFFER1,d0
  56.     moveq    #BUFFER2,d1
  57.     CALL    CopyBuffer
  58.  
  59. ;---------------------------------------------------------------------------;
  60. ;Initialise the restorelist.
  61.  
  62.     moveq    #2,d0    ;2 buffers.
  63.     moveq    #1,d1    ;1 BOB Entry.
  64.     CALL    InitRestore
  65.     move.l    d0,RestoreList
  66.     beq.s    .Error_RestoreList
  67.  
  68. ;---------------------------------------------------------------------------;
  69. ;Load the bob file in.  This contains the graphics data that we are
  70. ;going to draw to the screen.
  71.  
  72.     move.l    Screen(pc),a0    ;Initialise the BOB so that it is
  73.     lea    BBT_Rambo(pc),a1    ;ready for drawing.
  74.     CALL    InitBob
  75.     tst.l    d0
  76.     beq.s    .Error_Bob
  77.  
  78.     lea    SMT_Rambo(pc),a0
  79.     CALL    InitSound
  80.     tst.l    d0
  81.     beq.s    .Error_Sound
  82.  
  83.     move.l    Screen(pc),a0
  84.     CALL    ShowScreen
  85.  
  86.     bsr.s    Main
  87.  
  88. .ReturnToDOS
  89.     move.l    GMSBase(pc),a6
  90.     move.l    SND_Rambo(pc),a0
  91.     CALL    FreeSound
  92. .Error_Sound
  93.     move.l    BOB_Rambo(pc),a1
  94.     CALL    FreeBob
  95. .Error_BOB
  96.     move.l    RestoreList(pc),d0
  97.     CALL    FreeRestore
  98. .Error_RestoreList
  99.     move.l    PIC_Background(pc),a1
  100.     CALL    FreePic
  101. .Error_Picture
  102.     move.l    Screen(pc),a0
  103.     CALL    DeleteS creen
  104. .Error_Screen
  105.     CALL    FreeAudio
  106. .Error_Audio
  107.     CALL    FreeBlitter
  108. .Error_Blitter
  109.     MOVEM.L    (SP)+,A0-A6/D1-D7
  110.     moveq    #ERR_OK,d0
  111.     rts
  112.  
  113. ;===========================================================================;
  114. ;                                MAIN LOOP
  115. ;===========================================================================;
  116.  
  117. SPEED    =    5
  118. FIRESPEED =    0
  119.  
  120. Main:    move.l    GMSBase(pc),a6
  121.     CALL    InitJoyPorts
  122.     moveq    #$00,d7
  123.  
  124. .Loop    move.l    Screen(pc),a0
  125.     move.l    RestoreList(pc),a1
  126.     CALL    Restore
  127.  
  128.     move.l    BOB_Rambo(pc),a1
  129.     move.l    RestoreList(pc),a2
  130.     moveq    #BUFFER2,d0
  131.     CALL    DrawBOB    ;Blit the bob.
  132.     CALL    WaitVBL    ;Wait for VBL.
  133.     CALL    SwapBuffers
  134.     addq.w    #1,d7
  135.  
  136.     tst.b    FireState
  137.     bne.s    .FireOn
  138.  
  139.     cmp.w    #SPEED,d7
  140.     ble.s    .Move
  141.     moveq    #$00,d7
  142.     addq.w    #1,BOB_Frame(a1)
  143.     cmp.w    #9,BOB_Frame(a1)
  144.     blt.s    .Move
  145.     clr.w    BOB_Frame(a1)
  146.     bra.s    .Move
  147.  
  148. .FireOn    cmp.w    #FIRESPEED,d7
  149.     ble.s    .Move
  150.     moveq    #$00,d7
  151.     cmp.w    #10,BOB_Frame(a1)
  152.     bge.s    .On
  153.     move.w    #9,BOB_Frame(a1)
  154.  
  155. .On    addq.w    #1,BOB_Frame(a1)
  156.     cmp.w    #13,BOB_Frame(a1)
  157.     blt.s    .Move
  158.  
  159.     move.l    SND_Rambo(pc),a0
  160.     CALL    PlaySound
  161.  
  162.     btst    #MB_LMB,d0
  163.     beq.s    .Off
  164.     move.w    #11,BOB_Frame(a1)
  165.     bra.s    .Move
  166.  
  167. .Off    clr.w    BOB_Frame(a1)
  168.     clr.b    FireState
  169.  
  170. .Move    moveq    #JPORT1,d0    ;Read the mouse, then update the
  171.     moveq    #JT_ZBXY,d1    ;BOB's X and Y co-ordinates.
  172.     CALL    ReadJoyPort
  173.     move.w    d0,d1
  174.     ext.w    d0
  175.     add.w    d0,BOB_YPos(a1)
  176.     asr.w    #8,d1
  177.     add.w    d1,BOB_XPos(a1)
  178.  
  179.     btst    #MB_LMB,d0
  180.     beq.s    .chkRMB
  181.     st    FireState    ;Set fire to on.
  182. .chkRMB    btst    #MB_RMB,d0
  183.     beq    .Loop
  184.     rts
  185.  
  186. FireState:
  187.     dc.b    0
  188.     even
  189.  
  190. ;===========================================================================;
  191. ;                                  DATA
  192. ;===========================================================================;
  193.  
  194. RestoreList:    dc.l  0
  195.  
  196. ScreenTags:
  197.     dc.l    TAGS_GAMESCREEN
  198. Screen:    dc.l    0
  199.     dc.l    GSA_ScrWidth,320
  200.     dc.l    GSA_ScrHeight,256
  201.     dc.l    GSA_Planes,5
  202.     dc.l    GSA_Attrib,DBLBUFFER
  203.     dc.l    TAGEND
  204.  
  205. PIC_BackgroundTags:
  206.     dc.l    TAGS_PICTURE
  207. PIC_Background:
  208.     dc.l    0
  209.     dc.l    PCA_Data
  210. Data:    dc.l    0
  211.     dc.l    PCA_Width,320
  212.     dc.l    PCA_Height,256
  213.     dc.l    PCA_Planes,5
  214.     dc.l    PCA_Options,GETPALETTE
  215.     dc.l    PCA_File,.file
  216.     dc.l    TAGEND
  217. .file    dc.b    "GMS:demos/data/PIC.Green",0
  218.     even
  219.  
  220. ;---------------------------------------------------------------------------;
  221.  
  222. BBT_Rambo:
  223.     dc.l    TAGS_BOB
  224. BOB_Rambo:
  225.     dc.l    0
  226.     dc.l    BBA_Framelist,.frames
  227.     dc.l    BBA_Width,32
  228.     dc.l    BBA_Height,24
  229.     dc.l    BBA_XCoord,150
  230.     dc.l    BBA_YCoord,150
  231.     dc.l    BBA_ClipLX,32
  232.     dc.l    BBA_ClipRX,320-32
  233.     dc.l    BBA_ClipTY,32
  234.     dc.l    BBA_ClipBY,256-32
  235.     dc.l    BBA_Attrib,GENMASKS|CLIP|RESTORE
  236.     dc.l    BBA_PictureTags,.picture
  237.     dc.l    TAGEND
  238.  
  239. .frames    dc.w    000,00,0,0   ;0 X/Y Graphic, X/Y Mask
  240.     dc.w    032,00,0,0   ;1 ...
  241.     dc.w    064,00,0,0   ;2
  242.     dc.w    096,00,0,0   ;3
  243.     dc.w    128,00,0,0   ;4
  244.     dc.w    160,00,0,0   ;5
  245.     dc.w    192,00,0,0   ;6
  246.     dc.w    224,00,0,0   ;7
  247.     dc.w    256,00,0,0   ;8
  248.     dc.w    288,00,0,0   ;9
  249.     dc.w    000,48,0,0   ;10
  250.     dc.w    032,48,0,0   ;11
  251.     dc.w    064,48,0,0   ;12
  252.     dc.l    -1
  253. .picture
  254.     dc.l    TAGS_PICTURE,0
  255.     dc.l    PCA_Planes,5
  256.     dc.l    PCA_Options,BLITMEM
  257.     dc.l    PCA_FILE,.file
  258.     dc.l    TAGEND
  259.  
  260. .file    dc.b    "GMS:demos/data/PIC.Rambo",0
  261.     even
  262.  
  263. SMT_Rambo:
  264.     dc.l    TAGS_SOUND
  265. SND_Rambo:
  266.     dc.l    0
  267.     dc.l    SA_Channel,CHANNEL1
  268.     dc.l    SA_Octave,OCT_C2S
  269.     dc.l    SA_Volume,100
  270.     dc.l    SA_File,.file
  271.     dc.l    TAGEND
  272.  
  273. .file    dc.b    "GMS:demos/data/SND.Rambo",0
  274.     even
  275.  
  276.